/**************************************************************************************
 *  Copyright (c)  2010  Leszek Karcz, Changmin Bae.
 *  Permission is granted to copy, distribute and/or modify this document
 *  under the terms of the GNU Free Documentation License, Version 1.3
 *  or any later version published by the Free Software Foundation;
 *  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 *  A copy of the license is included in the section entitled "GNU
 *  Free Documentation License". 
 **************************************************************************************/
package data.tileables;
import data.Map;
import data.Player;
import data.missions.PowerDown;
import data.missions.PowerUp;

/**************************************************************************************
 * Author(s): Leszek Karcz, Changmin Bae
 * Watch Tower, a building with high vision radius
 **************************************************************************************/
public class WatchTower extends Structure
{
	public static final int [] PRICE = { 15, 20, 20};
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz, Changmin Bae
	 * WatchTower constructor
	 **************************************************************************************/
	public WatchTower(int ID, int supertypeID, Player player, int workers)
	{
		super(ID, supertypeID, player, workers);
		this.setType("Watch Tower");
		this.setImage("struct_tower");
		this.setIcon("struct_tower");
		this.setStats(5, 4, 100, 50, 0, 5, 3);
		this.setUpkeep(new int[]{0,1,1});
		this.setNumberOfCommands(2);
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz, Changmin Bae
	 * executes instructions regarding currently selected command
	 **************************************************************************************/
	public boolean enqueueSelectedCommand(String mode, Map m, int x, int y)
	{
		int selected=this.getSelectedCommand();
		if(this.isFinished())
		{
			switch(selected)
			{
				case 0:
					this.die();
					break;
				case 1:
					if(this.getState() == 0)
						this.addMission(new PowerUp(this));
					else
						this.addMission(new PowerDown(this));
					break;
			}
		}
		else
		{
			switch(selected)
			{
				case 0:
					this.die();
					break;
			}
		}
		
		
		
		return true;
	}
	
	/**************************************************************************************
	 * Author(s): Leszek Karcz, Changmin Bae
	 * returns list of possible commands
	 **************************************************************************************/
	public String[] getCommandsText()
	{
		if(this.isFinished())
		{
			return new String[]{"Decommision",(this.getState()==0 ? "Power up" : "Power down")};
		}
		else
		{
			return new String[]{"Cancel"};
		}
	}

	public void die()
	{ 
		super.die();
		this.player.removeTower(this);
	}
}
